import Dexie from 'dexie'
import data from './data'

const db = new Dexie('welcome_new_arrivals')

db.version(1).stores({
  students: '&id, recognized, classname'
})

db.on('populate', function() {
  Object.keys(data).forEach(key => {
    data[key].forEach(person => {
      db.students.add({...person, classname: key, recognized: 0})
    })
  })
})

db.open()

export default db
